<template>
	<div>
	
		<el-table :data="tableData" style="width: 100%;">
			<el-table-column type="selection" width="55">
			</el-table-column>
				<el-table-column label="编号" prop="id" sortable width="100"></el-table-column>
			<el-table-column label="用户id" prop="attendeeId" sortable width="100"></el-table-column>
			<el-table-column label="培训内容" prop="trainingContent" sortable width="200"></el-table-column>
			<el-table-column label="培训金额" prop="rainingCost" sortable width="200"></el-table-column>
			<el-table-column :formatter="formatDate" label="培训时间" prop="trainingCime" sortable width="200">
			</el-table-column>
			<!-- <el-table-column label="状态" prop="status" sortable width="200"></el-table-column> -->
			<el-table-column fixed="right" label="操作" width="200">
				<template slot-scope="scope">
					<el-switch v-model="scope.row.status" active-color="#d90000" active-text="未完成" active-value="未完成"
						inactive-color="#11d922" inactive-text="已完成" inactive-value="已完成"
						@change="handleEdit(scope.$index, scope.row)">
					</el-switch>
				</template>
			</el-table-column>
		</el-table>

	</div>

</template>

<script>
	export default {
		data() {
			return {
				tableData: [],
				pageInfo: {
					total: 10,
					currentPage: 1,
					pageNum: 1,
					pageSize: 10
				},
				formArticle: {
					title: '',
					status: '',
					pageNum: 1,
					pageSize: 3
				},
				sel: "all"
			}
		},

		methods: {
			formatDate(row, column, cellValue) {
				console.log(cellValue)
				let date = new Date(cellValue);
				return date.toLocaleString();
			},
		
			handleEdit(index, row) {
				var rowid = row.id
				var rowstatus = row.status
				this.$http.get("/RegisterUser/updateStatus", {
					params: {
						rowid,
						rowstatus
					}
				}).then(res => {
					if (res.data != "0") {
						row.status = res.data
					} else {
						this.$message({
							message: '服务器异常',
							type: 'error'
						});
					}
				}).catch((err) => {
					this.$message({
						message: '服务器异常' + err,
						type: 'error'
					});
				});
			},
		},
		created() {
			var that = this;
			console.log("sssss");
			console.log(this.num);
			// findMenuList  AdminByNum
			this.$http.post("/RegisterUser/getCulvate").then(function(res) {
				console.log("sss");
				if (res.data.code != "500") {
					that.tableData = res.data.data;
					console.log(res.data.data)
				}
			})
		}
	}
</script>
